import Vue from 'vue'
import VueRouter from 'vue-router'
import showInfor from '../components/Users/showInfor.vue'

import Oplogin from '../components/Oplogin.vue'
import Admin from '../components/Oper/Admin.vue'
 import Verify from '../components/Oper/Verify.vue'

//import Check from '../components/Check/Check.vue'

import User from '../components/Check/User.vue'
import AllStaff from '../components/Check/allStaff.vue'
import WRecord from '../components/Check/wRecord.vue'
import TRecord from '../components/Check/tRecord.vue'
import LRecord from '../components/Check/lRecord.vue'
import RRecord from '../components/Check/rRecord.vue'
import Charts from '../components/Check/charts.vue'





Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/choose'
  },

  {
    path:'/oplogin',
    component:Oplogin
  },
  {
    path:'/admin',
    component:Admin
  },
  {
    path:'/verify',
    component:Verify,
    children:[
      {path:'',component:Charts},
      {path:'/user',component:User},
      {path:'/wrecord',component:WRecord},
      {path:'/allstaff',component:AllStaff},
      {path:'/trecord',component:TRecord},
      {path:'/lrecord',component:LRecord},
      {path:'/rrecord',component:RRecord},
      {
        path: '/showInfor',
        component: showInfor
      },
    ]  
},

]

const router = new VueRouter({
  routes
})
router.beforeEach((to, from, next) => {
  if (to.path === '/oplogin') return next();
  //获取token
  const tokenStr = window.sessionStorage.getItem('token')
  if (!tokenStr) return next('/oplogin')
  next()
})
export default router
